Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

324
Vistas
Running into "TypeError: Cannot read properties of undefined (reading 'hasOwnProperty')" on Blog Posts

My blog posts are posted and are retrieved successfully when I follow the link from my blog page, however, if I copy the link and try to follow it independently I get this error:
"TypeError: Cannot read properties of undefined (reading 'hasOwnProperty')"

I built the Blog following this tutorial: https://www.youtube.com/watch?v=F6uZB1yls6Q&list=PLc_uiDBU7n2rP-5wOAoMnCE_bAzMe8_ty&index=5

Here is my code:


class ViewArticle extends Component {
    constructor(props) {
        super(props);
        this.state={
            article: {},
            isLoaded: false
        }
    }

    componentDidMount() {
        if(this.props.location.state !== 'undefined') {
            if(this.props.location.state.hasOwnProperty('article')){
                this.setState({
                    article: this.props.location.state.article
                }, () => {
                    this.setState({
                        isLoaded: true
                    })
                })
            }
        }else{
            this.getArticleByID(this.props.match.param.id)
        }
    }

    getArticleByID = (aid) => {
        db.collection('Articles')
        .doc(aid)
        .get()
        .then(doc => {
            if(doc.exists){
                this.setState({
                    article: doc.data()
                }, () => {
                    this.setState({
                        isLoaded: true
                    })
                })
            } else {
                this.props.history.push({pathname:'/'})
            }
        })
    }
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda